<?php
namespace App\Models;

use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class UserModel extends Authenticatable implements JWTSubject{

    use Notifiable;

    protected $table = 'user';

    /**
     * Get the identifier that will be stored in composer require tymon/jwt-auth:dev-develop --prefer-sourcethe subject claim of the JWT.
     *
     * @return mixed
     */
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    /**
     * Return a key value array, containing any custom claims to be added to the JWT.
     *
     * @return array
     */
    public function getJWTCustomClaims()
    {
        return [];
    }

    /**
     *
     */
    public function setPasswordAttribute($value){
        $this -> attributes['password'] = bcrypt($value);
    }

    /**
     * 获取器 获取头像
     */
    public function getHeadImgAttribute($value){
        return getDomain() . '/upload/' . $value;
    }

    /**
     * 获取器 获取身份证正面
     */
    public function getIdFrontAttribute($value){
        return getDomain() . '/upload/' . $value;
    }

    /**
     * 获取器 获取身份证反面
     */
    public function getIdBackAttribute($value){
        return getDomain() . '/upload/' . $value;
    }
}